## 项目启动
import time

from crawler.connection import filter_push_redis, redis_conn, redis_shedana

hk_list = {
    "HK": [
        {'category': 'Clothing>>Blouses', 'href': '/en-hk/shop/clothing/tops/blouses'},
        {'category': 'Clothing>>Coats', 'href': '/en-hk/shop/clothing/coats'},
        {'category': 'Clothing>>Dresses', 'href': '/en-hk/shop/clothing/dresses'},
        {'category': 'Clothing>>Jackets', 'href': '/en-hk/shop/clothing/jackets'},
        {'category': 'Clothing>>Jeans', 'href': '/en-hk/shop/clothing/jeans'},
        {'category': 'Clothing>>Jumpsuits', 'href': '/en-hk/shop/clothing/jumpsuits-and-playsuits'},
        {'category': 'Clothing>>Knitwear', 'href': '/en-hk/shop/clothing/knitwear'},
        {'category': 'Clothing>>Lingerie & Nightwear', 'href': '/en-hk/shop/lingerie'},
        {'category': 'Clothing>>Loungewear', 'href': '/en-hk/shop/clothing/loungewear'},
        {'category': 'Clothing>>Matching Separates', 'href': '/en-hk/shop/clothing/matching-separates'},
        {'category': 'Clothing>>Shorts', 'href': '/en-hk/shop/clothing/shorts'},
        {'category': 'Clothing>>Skirts', 'href': '/en-hk/shop/clothing/skirts'},
        {'category': 'Clothing>>Sport', 'href': '/en-hk/shop/sport'},
        {'category': 'Clothing>>Suits', 'href': '/en-hk/shop/clothing/suits'},
        {'category': 'Clothing>>Swimwear', 'href': '/en-hk/shop/clothing/swimwear-and-beachwear'},
        {'category': 'Clothing>>Tops', 'href': '/en-hk/shop/clothing/tops'},
        {'category': 'Clothing>>Trousers', 'href': '/en-hk/shop/clothing/pants'},
        {'category': 'Clothing>>Mini Dresses', 'href': '/en-hk/shop/clothing/dresses/mini-dresses'},
        {'category': 'Clothing>>Knee length dresses', 'href': '/en-hk/shop/clothing/dresses/knee-length-dresses'},
        {'category': 'Clothing>>Midi Dresses', 'href': '/en-hk/shop/clothing/dresses/midi-dresses'},
        {'category': 'Clothing>>Maxi Dresses', 'href': '/en-hk/shop/clothing/dresses/maxi-dresses'},
        {'category': 'Clothing>>Gowns', 'href': '/en-hk/shop/clothing/dresses/gowns'},
        {'category': 'Shoes>>Boots', 'href': '/en-hk/shop/shoes/boots'},
        {'category': 'Shoes>>Flat Shoes', 'href': '/en-hk/shop/shoes/flat-shoes'},
        {'category': 'Shoes>>Loafers', 'href': '/en-hk/shop/shoes/flat-shoes/loafers'},
        {'category': 'Shoes>>Pumps', 'href': '/en-hk/shop/shoes/pumps'},
        {'category': 'Shoes>>Sandals', 'href': '/en-hk/shop/shoes/sandals'},
        {'category': 'Shoes>>Sneakers', 'href': '/en-hk/shop/shoes/sneakers'},
        {'category': 'Bags>>Clutch Bags', 'href': '/en-hk/shop/bags/clutch-bags'},
        {'category': 'Bags>>Cross-Body Bags', 'href': '/en-hk/shop/bags/cross-body-bags'},
        {'category': 'Accessories>>Belts', 'href': '/en-hk/shop/accessories/belts'},
        {'category': 'Accessories>>Gloves', 'href': '/en-hk/shop/accessories/gloves'},
        {'category': 'Accessories>>Hats', 'href': '/en-hk/shop/accessories/hats'},
        {'category': 'Accessories>>Hair Accessories', 'href': '/en-hk/shop/accessories/hair-accessories'},
        {'category': 'Accessories>>Scarves and Wraps', 'href': '/en-hk/shop/accessories/scarves-and-wraps'},
        {'category': 'Accessories>>Sunglasses', 'href': '/en-hk/shop/accessories/sunglasses'},
        {'category': 'Accessories>>Wallets', 'href': '/en-hk/shop/accessories/wallets-and-cardholders'}
    ],

}
usa_list = {
    "USA": [

        {'category': 'Clothing>>Blouses', 'href': '/en-us/shop/clothing/tops/blouses'},
        {'category': 'Clothing>>Coats', 'href': '/en-us/shop/clothing/coats'},
        {'category': 'Clothing>>Dresses', 'href': '/en-us/shop/clothing/dresses'},
        {'category': 'Clothing>>Jackets', 'href': '/en-us/shop/clothing/jackets'},
        {'category': 'Clothing>>Jeans', 'href': '/en-us/shop/clothing/jeans'},
        {'category': 'Clothing>>Jumpsuits', 'href': '/en-us/shop/clothing/jumpsuits-and-playsuits'},
        {'category': 'Clothing>>Knitwear', 'href': '/en-us/shop/clothing/knitwear'},
        {'category': 'Clothing>>Lingerie & Nightwear', 'href': '/en-us/shop/lingerie'},
        {'category': 'Clothing>>Loungewear', 'href': '/en-us/shop/clothing/loungewear'},
        {'category': 'Clothing>>Matching Separates', 'href': '/en-us/shop/clothing/matching-separates'},
        {'category': 'Clothing>>Shorts', 'href': '/en-us/shop/clothing/shorts'},
        {'category': 'Clothing>>Skirts', 'href': '/en-us/shop/clothing/skirts'},
        {'category': 'Clothing>>Sport', 'href': '/en-us/shop/sport'},
        {'category': 'Clothing>>Suits', 'href': '/en-us/shop/clothing/suits'},
        {'category': 'Clothing>>Swimwear', 'href': '/en-us/shop/clothing/swimwear-and-beachwear'},
        {'category': 'Clothing>>Tops', 'href': '/en-us/shop/clothing/tops'},
        {'category': 'Clothing>>Trousers', 'href': '/en-us/shop/clothing/pants'},
        {'category': 'Clothing>>Mini Dresses', 'href': '/en-us/shop/clothing/dresses/mini-dresses'},
        {'category': 'Clothing>>Knee length dresses', 'href': '/en-us/shop/clothing/dresses/knee-length-dresses'},
        {'category': 'Clothing>>Midi Dresses', 'href': '/en-us/shop/clothing/dresses/midi-dresses'},
        {'category': 'Clothing>>Maxi Dresses', 'href': '/en-us/shop/clothing/dresses/maxi-dresses'},
        {'category': 'Clothing>>Gowns', 'href': '/en-us/shop/clothing/dresses/gowns'},
        {'category': 'Shoes>>Boots', 'href': '/en-us/shop/shoes/boots'},
        {'category': 'Shoes>>Flat Shoes', 'href': '/en-us/shop/shoes/flat-shoes'},
        {'category': 'Shoes>>Loafers', 'href': '/en-us/shop/shoes/flat-shoes/loafers'},
        {'category': 'Shoes>>Pumps', 'href': '/en-us/shop/shoes/pumps'},
        {'category': 'Shoes>>Sandals', 'href': '/en-us/shop/shoes/sandals'},
        {'category': 'Shoes>>Sneakers', 'href': '/en-us/shop/shoes/sneakers'},
        {'category': 'Bags>>Clutch Bags', 'href': '/en-us/shop/bags/clutch-bags'},
        {'category': 'Bags>>Cross-Body Bags', 'href': '/en-us/shop/bags/cross-body-bags'},
        {'category': 'Accessories>>Belts', 'href': '/en-us/shop/accessories/belts'},
        {'category': 'Accessories>>Gloves', 'href': '/en-us/shop/accessories/gloves'},
        {'category': 'Accessories>>Hats', 'href': '/en-us/shop/accessories/hats'},
        {'category': 'Accessories>>Hair Accessories', 'href': '/en-us/shop/accessories/hair-accessories'},
        {'category': 'Accessories>>Scarves and Wraps', 'href': '/en-us/shop/accessories/scarves-and-wraps'},
        {'category': 'Accessories>>Sunglasses', 'href': '/en-us/shop/accessories/sunglasses'},
        {'category': 'Accessories>>Wallets', 'href': '/en-us/shop/accessories/wallets-and-cardholders'}
    ],
}
mac_list = {
    "MACUA": [

        {'category': 'Clothing>>Blouses', 'href': '/en-mo/shop/clothing/tops/blouses'},
        {'category': 'Clothing>>Coats', 'href': '/en-mo/shop/clothing/coats'},
        {'category': 'Clothing>>Dresses', 'href': '/en-mo/shop/clothing/dresses'},
        {'category': 'Clothing>>Jackets', 'href': '/en-mo/shop/clothing/jackets'},
        {'category': 'Clothing>>Jeans', 'href': '/en-mo/shop/clothing/jeans'},
        {'category': 'Clothing>>Jumpsuits', 'href': '/en-mo/shop/clothing/jumpsuits-and-playsuits'},
        {'category': 'Clothing>>Knitwear', 'href': '/en-mo/shop/clothing/knitwear'},
        {'category': 'Clothing>>Lingerie & Nightwear', 'href': '/en-mo/shop/lingerie'},
        {'category': 'Clothing>>Loungewear', 'href': '/en-mo/shop/clothing/loungewear'},
        {'category': 'Clothing>>Matching Separates', 'href': '/en-mo/shop/clothing/matching-separates'},
        {'category': 'Clothing>>Shorts', 'href': '/en-mo/shop/clothing/shorts'},
        {'category': 'Clothing>>Skirts', 'href': '/en-mo/shop/clothing/skirts'},
        {'category': 'Clothing>>Sport', 'href': '/en-mo/shop/sport'},
        {'category': 'Clothing>>Suits', 'href': '/en-mo/shop/clothing/suits'},
        {'category': 'Clothing>>Swimwear', 'href': '/en-mo/shop/clothing/swimwear-and-beachwear'},
        {'category': 'Clothing>>Tops', 'href': '/en-mo/shop/clothing/tops'},
        {'category': 'Clothing>>Trousers', 'href': '/en-mo/shop/clothing/pants'},
        {'category': 'Clothing>>Mini Dresses', 'href': '/en-mo/shop/clothing/dresses/mini-dresses'},
        {'category': 'Clothing>>Knee length dresses', 'href': '/en-mo/shop/clothing/dresses/knee-length-dresses'},
        {'category': 'Clothing>>Midi Dresses', 'href': '/en-mo/shop/clothing/dresses/midi-dresses'},
        {'category': 'Clothing>>Maxi Dresses', 'href': '/en-mo/shop/clothing/dresses/maxi-dresses'},
        {'category': 'Clothing>>Gowns', 'href': '/en-mo/shop/clothing/dresses/gowns'},
        {'category': 'Shoes>>Boots', 'href': '/en-mo/shop/shoes/boots'},
        {'category': 'Shoes>>Flat Shoes', 'href': '/en-mo/shop/shoes/flat-shoes'},
        {'category': 'Shoes>>Loafers', 'href': '/en-mo/shop/shoes/flat-shoes/loafers'},
        {'category': 'Shoes>>Pumps', 'href': '/en-mo/shop/shoes/pumps'},
        {'category': 'Shoes>>Sandals', 'href': '/en-mo/shop/shoes/sandals'},
        {'category': 'Shoes>>Sneakers', 'href': '/en-mo/shop/shoes/sneakers'},
        {'category': 'Bags>>Clutch Bags', 'href': '/en-mo/shop/bags/clutch-bags'},
        {'category': 'Bags>>Cross-Body Bags', 'href': '/en-mo/shop/bags/cross-body-bags'},
        {'category': 'Accessories>>Belts', 'href': '/en-mo/shop/accessories/belts'},
        {'category': 'Accessories>>Gloves', 'href': '/en-mo/shop/accessories/gloves'},
        {'category': 'Accessories>>Hats', 'href': '/en-mo/shop/accessories/hats'},
        {'category': 'Accessories>>Hair Accessories', 'href': '/en-mo/shop/accessories/hair-accessories'},
        {'category': 'Accessories>>Scarves and Wraps', 'href': '/en-mo/shop/accessories/scarves-and-wraps'},
        {'category': 'Accessories>>Sunglasses', 'href': '/en-mo/shop/accessories/sunglasses'},
        {'category': 'Accessories>>Wallets', 'href': '/en-mo/shop/accessories/wallets-and-cardholders'}
    ]
}
for country, v in hk_list.items():
    for index, url in enumerate(v):
        if "HK" == country:
            currency = 'HKD'
        elif "USA" == country:
            currency = "USD"
        else:
            currency = 'MOP'
        task = {
            "jobId": index,
            'url': url,
            "currency": currency,
            'country': country,
            'domain': 'porter'.upper(),
            'filename': 'main',
            'types': 'electronic_business',
            "scheduleTime": int(time.time() * 1000),
            "triggerChannel": 'SONIC_SPIDER',
        }
        result = filter_push_redis(redis_conn, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        # result = filter_push_redis(redis_shedana, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        print(result)
#         input()
for country, v in usa_list.items():
    for index, url in enumerate(v, start=200):
        if "HK" == country:
            currency = 'HKD'
        elif "USA" == country:
            currency = "USD"
        else:
            currency = 'MOP'
        task = {
            "jobId": index,
            'url': url,
            "currency": currency,
            'country': country,
            'domain': 'porter'.upper(),
            'filename': 'main',
            'types': 'electronic_business',
            "scheduleTime": int(time.time() * 1000),
            "triggerChannel": 'SONIC_SPIDER',
        }
        result = filter_push_redis(redis_conn, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        # result = filter_push_redis(redis_shedana, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        print(result)
        # input()

for country, v in mac_list.items():
    for index, url in enumerate(v, start=400):
        if "HK" == country:
            currency = 'HKD'
        elif "USA" == country:
            currency = "USD"
        else:
            currency = 'MOP'
        task = {
            "jobId": index,
            'url': url,
            'country': country,
            "currency": currency,
            'domain': 'porter'.upper(),
            'filename': 'main',
            'types': 'electronic_business',
            "scheduleTime": int(time.time() * 1000),
            "triggerChannel": 'SONIC_SPIDER',
        }
        result = filter_push_redis(redis_conn, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        # result = filter_push_redis(redis_shedana, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
        print(result)
        # input()
